package zh.cgserver.core;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class WebServerApplication {
    ServerSocket serverSocket ;
    public WebServerApplication(){
        try {
            System.out.println("正在启动服务端...");
            serverSocket =  new ServerSocket(8089);
            System.out.println("服务端启动成功...");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public void start(){

        try {
            System.out.println("等待客户端连接..");
            Socket accept = serverSocket.accept();
            System.out.println("一个客户端已连接");

            ClientHandler clientHandler = new ClientHandler(accept);
            Thread t1 = new Thread(clientHandler);
            t1.start();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    public static void main(String []args){
        WebServerApplication webServerApplication  = new WebServerApplication();
        webServerApplication.start();
    }
}
